Repository navigation
fix(eager): keep nested import alias paths consistent with flattened parent imports - #1369
Open
mnobile-hs wants to merge 2 commits into
Open
mnobile-hs wants to merge 2 commits into
mnobile-hs wants to merge 2 commits into
Conversation
Since #1368, an aliased import inside a macro from another aliased import is bound in the current scope once the parent import has finished, instead of being nested under the parent's alias map. Its full import alias was still the dotted `parent.child` path, though, and that is the path any import inside the child file walks to find where to nest its own alias map. So if a file imported this way has its own top-level aliased import, that import walks `parent.child`, finds nothing at `child`, and fails with "Encountered a problem with import alias maps". The error aborts the whole macro call, and eager output loses everything the macro would have rendered. Default execution mode renders it normally. Decide once, in the constructor, whether to nest under the parent (only while the parent import is still in progress), and build the full import alias from that decision. Imports inside a flattened import then nest under its alias map's actual location. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…block While a macro runs in a deferred block, the temporary alias of the import it came from is in scope. Before the previous commit, an import inside one of that file's macros therefore treated its flattened parent as still importing and walked the stale dotted alias, failing with "Encountered a problem with import alias maps". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mnobile-hs
marked this pull request as ready for review
November 23, 2026 18:44
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#1368 stopped nesting an aliased import's alias map under its parent's once the parent import has finished, and binds it in the current scope instead. The import's full alias was still recorded as the dotted
parent.childpath, though. Imports inside the child file use that path to find where to nest their own alias maps, so a file imported this way that has its own top-level aliased import walksparent.child, finds nothing atchild, and fails withInterpretException: Encountered a problem with import alias maps. The error aborts the whole macro call, so eager output is missing everything the macro would have rendered, while default execution mode renders it normally.For example, with
{% import 'outer.jinja' as outer %}{{ outer.render() }}, whererender()inouter.jinjadoes{% import 'middle.jinja' as middle %}{{ middle.go() }}andmiddle.jinjastarts with{% import 'printer.jinja' as printer %}.The same failure happens without a top-level import when the outer macro is called inside a deferred block: while the deferred macro runs, the child import's temporary alias is in scope, so an import inside one of the child file's macros also treats its flattened parent as still importing and walks the stale dotted path.
AliasedEagerImportingStrategynow decides once, in its constructor, whether the import nests under its parent (only while the parent import is still in progress, the same check fix(eager): don't nest import aliases under a parent import that has finished #1368 added), and builds the full import alias from that decision.constructFullAliasPathMapalways walks the full import alias, which now matches where the maps live.Testing
EagerImportTagTest.itImportsTopLevelAliasOfFileImportedInsideMacroFromAliasedImportfails without this change withEncountered a problem with import alias maps, and passes with it.EagerImportTagTest.itImportsInsideMacroOfImportFromMacroCalledInDeferredBlockfails without this change with the same error, and passes with it.This description was authored by Claude Code.
🤖 Generated with Claude Code